/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package muse.widgets;

import java.awt.*;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import muse.Frame;
import muse.Launcher;

/**
 *
 * @author joe
 */
public class ChatBubbleWidget extends Widget{
        private JLabel text;
        JTextArea textArea;
        Toolkit tk = Toolkit.getDefaultToolkit();
        Image Img = tk.getImage(getClass().getClassLoader().getResource("muse/resources/muse_chatBubble_dummy.png"));
        
        
	public ChatBubbleWidget()
        {
            this.setLayout(new BorderLayout());
            
            textArea = new JTextArea();
            textArea.setEditable(false);
            textArea.setBackground(null);
            textArea.setOpaque(false);
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setVisible(true);
            textArea.setSize(100, 175);
            textArea.setLocation(20, 20);
            
            
            
            JPanel all = new JPanel(){
                public void paintComponent(Graphics g)
                {
                    
                    //getWidth()/2 - Img.getWidth(null)/2, getHeight()/2 - Img.getHeight(null)/2
                    g.drawImage(Img, 0, 0, getWidth(), getHeight(), null);
                    
                    
                }
            };
            
            all.setLayout(new BorderLayout());
            this.add(textArea);
            this.add(all);
            
            new Timer().scheduleAtFixedRate(new TimerTask() {
			public void run() {
                                    Random rng = new Random();
                                    textArea.setText(Launcher.greetings[rng.nextInt(6)]);
                                    textArea.setBackground(null);
                                    textArea.setOpaque(false);
			}
		}, 100, 5000);
        }

        
	public ChatBubbleWidget(String s) {
		super();
		text = new JLabel();
		text.setText(s);
	}

	@Override
	public Dimension getPreferredSize() {
		return new Dimension(115, 182);
	}

	@Override
	public String getIcon() {
		return "";
	}

}
